// 用于定义广告相关的schema和model

// 引入mongoose
const mongoose = require('mongoose')

// 创建schema对象

const schema = new mongoose.Schema({
  title: {
    type: String,
    required: true,
    unique: true,
  },
  img_url: {
    type: String,
    required: true,
  },

  category: {
    type: String,
    required: true,
  },
  link: {
    type: String,
    required: true,
  },
  insert_date: {
    type: Date,
    default: Date.now(),
  },
  update_date: {
    type: Date,
    default: Date.now(),
  },
})

// 创建model
const model = mongoose.model('advs', schema)

module.exports = model
